package com.action;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bean.ResponseBean;
import com.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: T-bao
 * @Date: 2021-4-14 9:24
 * @Description:
 */
@RestController
@RequestMapping("/country")
public class CountryAction {

    @Autowired
    private CountryService countryService;

    /**
     * 根据国籍名称分页查询可以显示国籍
     */
    @RequestMapping("/selectGuojia")
    public ResponseBean selectCountry(String name, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){
        IPage iPage = countryService.selectCountry(name,page,limit);
        return new ResponseBean(0,iPage.getTotal(),"成功",iPage.getRecords());
    }

    /**
     * 查询所有可显示的国家  不分页
     * @return
     */
    @RequestMapping("/selectCountry")
    public ResponseBean selectGuojia(){
        return new ResponseBean(0,1,"",countryService.selectGuojia());
    }
}
